1. Field of the Invention
The present invention relates to an encoder for encoding an image in a transcoder or the like, and more particularly to a technique to average the amount of generated codes outputted from the encoder.
2. Description of the Background Art
Images to be delivered on digital broadcasts, those to be stored in media such as DVDs and hard disks, and the like are compressed by an encoder in accordance with various coding systems. The object for such compressions is to avoid constraint on a transmission band, increase the transmission speed, decrease the memory size, or the like.
There are various standards for image coding system, such as MPEG2 and H.264. And there is a case where the coding system is converted for the purpose of reducing the amount of codes of a coded image that is inputted, or the like. A transcoder (or a translator) once decodes the inputted coded image. Then, the transcoder codes the decoded image in a different coding system (or the same coding system) again. Thus, the transcoder controls a bit rate of an output stream.
The encoder performs stuffing to average the amount of generated codes of an output stream in a unit time. If the amount of generated codes is smaller than the target amount of codes, the encoder adds dummy data, i.e., stuffing bits, in order to adjust the amount of codes of the output stream.
Specifically, since the target bit rate of the whole output stream is set by a user, the target amount of codes in a unit of GOP (Group Of Pictures) can be calculated. Then, the amount of generated codes of an output stream in a unit of GOP is acquired, the difference between the target amount of codes and the amount of generated codes is obtained by the unit of GOP and the shortage in the amount of codes is supplemented by the stuffing bits.
In Japanese Patent Application Laid Open Gazette No. 10-191331, addition of the stuffing bits is performed by the unit of two GOPs to average the amount of generated codes of an output stream.
In Japanese Patent Application Laid Open Gazette No. 2000-32449, the amount of generated codes in a unit of GOP is counted, and if the count value is smaller than the target amount of codes, stuffing is performed, or if the count value is larger than the target amount of codes, the non-zero coefficient that is the higher order of the DCT coefficient is substituted with “0”.
As discussed above, conventionally, stuffing is performed to average the bit rate of an output stream. Since stuffing is performed by the unit of GOP, however, there arises some delay in the transcoding operation for the next GOP. In other words, the operation can not be performed in real time, and this causes some delay between an input stream and an output stream in a transcoder.
There is another case where stuffing bits are added since the amount of generated codes is smaller than the target amount of codes in a specified GOP but the amount of generated codes is larger than the target amount of codes in the other GOPs. In this case, there is a possibility that the bit rate of the whole output stream may exceed the target bit rate set by the user. If the bit rate of the whole output stream exceeds the target bit rate, there arises some problem, such as the outputted stream can not be recorded in a recording medium.
In Japanese Patent Application Laid Open Gazette No. 2000-32449, some consideration is given in order for the bit rate of the whole output stream not to exceed the target bit rate. If the amount of generated codes is larger than the target amount of codes, however, the high-frequency component of an image is deleted since the non-zero coefficient that is the higher order of the DCT coefficient is substituted with “0”. Since dummy data, i.e., the stuffing bits are added in some GOPs and some image information is deleted in the other GOPs, this invention is susceptible to improvement.